<template>
	<view>
		
		<u-navbar  :border-bottom="false" placeholder="" autoBack>
			<view slot="center" style="width: 300rpx;">
				<u-search v-model="keyword" placeholder="搜索您要的商品"  :showAction="false" margin="0 0 0 -146rpx"
					></u-search>
			</view>
		</u-navbar>
		
		<template v-if="list.length">
			<view class="flex justify-between bg-white" style="flex-wrap: wrap;margin:0 30rpx;">
				<block v-for="(item,index) in list" :key="index">
					<commonItem :item="item"></commonItem>
				</block>
			</view>
		</template>
		<template v-else>
			<u-empty mode="search" marginTop="150"></u-empty>
		</template>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				keyword:'',
				page:1,
				list:[]
			}
		},
		onLoad(e) {
			this.keyword = e.keyword
			this.getData()
		},
		methods: {
			getData(){
				this.$api.indexGoods({
					search:this.keyword,
					page:this.page
				}).then(res=>{
					if(res.code === 1){
						this.list = res.data
					}
				})
			}
		}
	}
</script>

<style>

</style>
